<template>
  <div>
    <el-container>
      <!-- <el-aside width="400px">
        <el-image
          style="width: 300px; height: 300px; margin: 100px 50px 10px 50px"
          :src="url"
          fit="fill"
        ></el-image>
        <el-upload
          class="upload-demo"
          action="http://101.43.44.19:8080/api/upload/image"
          :on-success="handleAvatarSuccess"
          :show-file-list="false"
        >
          <el-button size="small" style="margin-left: 150px" type="primary"
            >点击上传</el-button
          >
        </el-upload>
        <el-button
          size="small"
          style="margin: 10px 0 0 140px"
          :disabled="edit"
          type="primary"
          @click="editImage"
          >确认修改营业执照</el-button
        >
      </el-aside> -->
      <el-main>
        <el-descriptions
          direction="vertical"
          class="margin-top"
          title="公司信息"
          :column="2"
          border
        >
          <!-- <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-message"></i>
              邮箱
            </template>
            {{ info.email }}
          </el-descriptions-item> -->

          <!-- <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-key"></i>
              密码
            </template>
            <div style="display: flex; align-items: center">
              <template v-if="!showPassword">{{
                info.password.replace(/./g, "*")
              }}</template>
              <template v-else>{{ info.password }}</template>
              <div style="margin-left: 10px">
                <el-button
                  icon="el-icon-lock"
                  circle
                  v-if="!showPassword"
                  size="mini"
                  @click="toggleShowPassword"
                  :border="false"
                >
                </el-button>
                <el-button
                  v-else
                  icon="el-icon-view"
                  circle
                  size="mini"
                  @click="toggleShowPassword"
                  :border="false"
                >
                </el-button>
              </div>
            </div>
          </el-descriptions-item> -->

          <!-- <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-circle-check"></i>
              注册时间
            </template>
            {{ info.regtime }}
          </el-descriptions-item>

          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-date"></i>
              更新时间
            </template>
            {{ info.updated }}
          </el-descriptions-item> -->

          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-office-building"></i>
              公司名称
            </template>
            {{ info.name }}
          </el-descriptions-item>

          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-info"></i>
              公司ID
            </template>
            {{ info.id }}
          </el-descriptions-item>

          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-s-flag"></i>
              统一信用代码
            </template>
            {{ info.creditCode }}
          </el-descriptions-item>

          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-user-solid"></i>
              法定代表人
            </template>
            {{ info.legalPerson }}
          </el-descriptions-item>

          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-place"></i>
              地区ID
            </template>
            {{ info.areaId }}
          </el-descriptions-item>

          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-location-outline"></i>
              公司地址
            </template>
            {{ info.address }}
          </el-descriptions-item>

          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-user"></i>
              联系人姓名
            </template>
            {{ info.contact }}
          </el-descriptions-item>

          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-phone"></i>
              联系人电话
            </template>
            {{ info.phone }}
          </el-descriptions-item>

          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-s-check"></i>
              营业执照
            </template>
            {{ info.businessLicense }}
          </el-descriptions-item>

          <!-- <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-loading"></i>
              状态
            </template>
            {{ info.status }}
          </el-descriptions-item> -->
        </el-descriptions>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "companyInfo",
  data() {
    return {
      showPassword: false,
      // info: {
      //   id: "",
      //   userId: "",
      //   companyId: "",
      //   labelId: "",
      //   type: "",
      //   salary: "",
      //   email: "",
      //   password: "",
      //   name: "",
      //   sex: "",
      //   birth: "",
      //   phone: "",
      //   address: "",
      //   faceUrl: "",
      //   status: "",
      //   createTime: "",
      // },
      info: {
        id: "",
        name: "",
        creditCode: "",
        legalPerson: "",
        businessLicense: "",
        contact: "",
        phone: "",
        areaId: "",
        address: "",
      },
      edit: false,
      url: "",
      listLoading: false,
    };
  },
  created() {
    this.getinfo();
  },
  methods: {
    getinfo() {
      this.listLoading = true;
      this.axios
        .get("/api/company/auth/user/getInfo")
        .then((response) => {
          console.log(response);
          if (response.data.code == "200") {
            this.info = response.data.value.company;
            console.log(this.info);
          } else {
            this.$message.error(response.data.message);
          }
          this.listLoading = false;
        })
        .catch((error) => {
          this.message.error("无法获取数据");
          this.listLoading = false;
        });
    },
    toggleShowPassword() {
      this.showPassword = !this.showPassword;
    },
    handleAvatarSuccess(res) {
      if (res.code != "200") {
        this.$message.error("文件格式不支持");
      } else {
        this.$message({
          message: "上传成功",
          type: "success",
        });
        this.url = res.value;
        this.edit = false;
      }
    },
  },
};
</script>
